#!/usr/bin/env node

//const http = require('http'),
      //url = require('url');

//const addr = 'http://localhost:3000';
//const opt = url.parse(addr);
//opt.method = 'post';

//const req = http.request(opt, (res) => {
  //res.pipe(process.stdout);
//})

//req.end('userName=wangding&password=1234');


const http = require('http'),
      url = require('url'),
      log = console.log;

let msg = process.argv[2] || 'Hello! I am wangding.',
    opt= url.parse('http://localhost:8080');

    opt.method = 'POST';

let req = http.request(opt, (res) => {
      log(`HTTP/${res.httpVersion} ${res.statusCode} ${res.statusMessage}`);
      log(res.headers);
      log('');

      res.pipe(process.stdout);
});

req.end(msg + '\n');
